package dxunderground.utilities.server;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

import javax.swing.DefaultListModel;

public class Client {
	private PrintWriter out;
	BufferedReader in;

	public Client() {
		String host = "localhost";
		try {
			Socket socket = new Socket(host, 4444);
			out = new PrintWriter(socket.getOutputStream(), true);
			in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		} catch (UnknownHostException e) {
			System.err.println("Don't know about host: " + host);
		} catch (IOException e) {
			System.err.println("Couldn't get I/O for the connection to: " + host);
		}
	}

	public void getPlaylist(DefaultListModel listModel) {
		out.println("Get Playlist");
		try {
			String song = in.readLine();
			System.out.println(song);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
